const install = (Vue,vm) => {

    const check = (auth = false) =>
    {
        let LoginAdmin = uni.getStorageSync('admin') || '';

        if(!LoginAdmin)
        {
            uni.showToast({
                title:'请先登录',
                icon:'error',
                success:() => {
                    if(auth === true)
                    {
                        setTimeout(() => {
                            // #ifdef MP-WEIXIN
                            uni.switchTab({
                                url:'/pages/admin/index'
                            });
                            // #endif

                            // #ifdef H5 || APP-PULS
                            uni.navigateTo({
                                url:'/pages/admin/login'
                            });
                            // #endif
                        },1500);
                    }
                }
            });

            return false;
        }

        return true;
    }

    vm.$u.tools = {
        check
    }
}

export default {
    install
}